package com.rizzo.web.breadcrumb;

import java.io.Serializable;

/**
 * Breadcrumb value holder containing the viewState identifier and label. The viewState identifier is used by Spring
 * Webflow to navigate to the defined view. The label can be used as displaylabel, to give the breadcrumb a more
 * meaningful name.
 */
public class Breadcrumb implements Serializable {

    /** Field index  */
    private Integer index;

    /** Field viewState  */
    private String viewState;

    /** Field label  */
    private String label;

    /**
     * Default constructor
     *
     * @param index of type int
     * @param viewState The viewState
     * @param label     Display label
     */
    public Breadcrumb(int index, String viewState, String label) {
        this.viewState = viewState;
        this.label = label;
        this.index = index;
    }

    /**
     * Method getViewState returns the viewState of this Breadcrumb object.
     *
     * @return the viewState (type String) of this Breadcrumb object.
     */
    public String getViewState() {
        return this.viewState;
    }

    /**
     * Method setViewState sets the viewState of this Breadcrumb object
     *
     * @param viewState of type String
     */
    public void setViewState(String viewState) {
        this.viewState = viewState;
    }

    /**
     * Method getLabel returns the label of this Breadcrumb object.
     *
     * @return the label (type String) of this Breadcrumb object.
     */
    public String getLabel() {
        return this.label;
    }

    /**
     * Method setLabel sets the label of this Breadcrumb object
     *
     * @param label of type String
     */
    public void setLabel(String label) {
        this.label = label;
    }

    /**
     * Method getIdx returns the index of this Breadcrumb object.
     *
     * @return the idx (type Integer) of this Breadcrumb object.
     */
    public Integer getIndex() {
        return index;
    }

    /**
     * Method setIdx sets the idx of this Breadcrumb object
     *
     * @param index of type Integer
     */
    public void setIndex(Integer index) {
        this.index = index;
    }

    /**
     * TODO Method hashCode
     *
     * @return int
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.viewState == null) ? 0 : this.viewState.hashCode());
        return result;
    }

    /**
     * TODO Method equals ...
     *
     * @param other of type Object
     * @return boolean
     */
    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (!(other instanceof Breadcrumb)) {
            return false;
        }
        Breadcrumb oBreadcrumb = (Breadcrumb) other;
        return this.viewState.equals(oBreadcrumb.viewState);
    }

}